import {router} from '@/router.js';
import storage from '@/model/storage';
import wx from "weixin-jsapi";
//路由跳转
const toUrl = (url) => { router.push(url) };
const isLogin = () => Boolean(storage.get('userToken'));
//包裹根据status 计算对应的文字展示内容
const renderStatusTxt = status => ['','未到库','已和包','已发货'][Number(status)];
//获取固定的货物类型
const getPullTypes = () => [
    {name:"普通",id:1},
    {name:"敏感",id:2},
];
const appId = 'wxe7b1bfeeb7252fbc';
const wxShare = (type,id) => { //1是微信好友  2是朋友圈
    wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
        if(type == 1){
            wx.updateAppMessageShareData({ 
                title: '东风中泰速递', // 分享标题
                desc: '中到泰专业物流运输',   // 分享描述
                link: 'http://syb.longxiaokj.com/login?inviteId='+id, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                imgUrl: 'https://wuliang666.oss-cn-beijing.aliyuncs.com/image/logo.png', // 分享图标
                success: function () {
                    //设置成功
                }
            })
        }else if(type == 2){ 
            wx.updateTimelineShareData({ 
                title: '东风中泰速递', // 分享标题
                link: 'http://syb.longxiaokj.com/login?inviteId='+id, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                imgUrl: 'https://wuliang666.oss-cn-beijing.aliyuncs.com/image/logo.png', // 分享图标
                success: function () {
                    //设置成功
                }
            })
        }
    });
}
export {
    toUrl,
    isLogin,
    renderStatusTxt,
    getPullTypes,
    appId,
    wxShare,
}